<template>
    <div class="execution">
    <div class="bg-container">
        <div class="title">
          <h2>基本信息</h2>
          <el-row>
            <el-col :span="4">
              商品名称: <span>{{info.goodsName}}</span>
            </el-col>
            <el-col :span="4">
              汇总单号: <span>{{info.summaryOrderId}}</span>
            </el-col>
          </el-row>
        </div>
        <div class="content">
          <avue-crud :option="option" :data="tableData">
<!--             <template slot="search">
              <el-form-item label="商品规格名称">
                <el-input placeholder="请输入客户名称" size="medium" v-model="searchForm.solt" />
              </el-form-item>
              <el-form-item label="订单编号">
                <el-input placeholder="请输入订单编号" size="medium" v-model="searchForm.solt" />
              </el-form-item>
            </template> -->
            <template slot-scope="scope" slot="menu">
                <el-button type="text"
                           size="small"
                           plain
                           @click="cancelOrder(scope.row)">移除
                </el-button>
            </template>
          </avue-crud>
        </div>
      </div>
    </div>
</template>

<script>
  import {cancelOrder} from '@/api/saleb/buyorder'
  import {queryWaitSummaryOrderDetail} from "../../../../api/scm/order/summary_order";
  import Util from '@/util/pds/utils'
  import dictionary from '@/util/pds/dictionary'
  import {getStore, setStore} from "@/util/store";
  let cookieUtil = new Util();
    export default {
        name: "index",
        data() {
            return {
                pmId: getStore({name: "pmId"}),
                searchForm: {},
                tableData: [],
                info:{
                  goodsName:"",
                  summaryOrderId:""
                },
                status:{
                  1:"待处理",2:"待审核",3:"采购中",4:"备货中",5:"已揽货",6:"采购完成",7:"部分完成",8:"已关闭"
                },
                option: {
                    menu: true,
                    addBtn: false,
                    delBtn:false,
                    editBtn: false,
                    delBtn: false,
                    selectClearBtn:false,
                    column: [
                      {
                        label: '订单编号',
                        prop: 'buyId',
                      },
                      {
                        label: '商品规格名称',
                        prop: 'goodsModel',
                      },
                      {
                        label: '下单时间',
                        prop: 'createDate',
                      },
                      {
                        label: '采购价格',
                        prop: 'buyPrice',
                      },
                      {
                        label: '付款状态',
                        prop: 'status',
                        formatter:function(value,row,column){
                          return dictionary.buyerOption[""+value.status];
                        }

                      },
                      {
                        label: '下单价格',
                        prop: 'buyPrice',

                      },
                      {
                        label: '下单数量',
                        prop: 'orderGoodsNum',

                      },
                      ]
                }
            }
        },
        created(){
          this.init();
        },
        methods:{
          cancelOrder(data){
            let param = {
              buyId:data.buyId,
              id:data.id,
              pmId:data.pmId,
            }
            cancelOrder(param).then(res => {
              this.$message.success('移除成功');
              this.init()
            }).catch(e => {

            });
          },
          searchChange(params) {
            // this.$message.success('search callback' + JSON.stringify(Object.assign(params, this.searchForm)))
            console.log(params);
            let query = {
                
            }
          },
          init(){
            this.info = {
              goodsName:this.$route.query.row.goodsName,
              summaryOrderId:this.$route.query.row.summaryOrderId,
            }
            let query = {
              pmId: this.pmId,
              goodsModelId: this.$route.query.row.goodsModelId,
              buySeq: this.$route.query.row.buySeq,
              deliveryTime: this.$route.query.row.deliveryTime,
            }
            if(this.$route.query.row.summaryOrderId=="" || this.$route.query.row.summaryOrderId == undefined || this.$route.query.row.summaryOrderId == null){
              query.summaryFlag = '0'
            }else {
              query.summaryFlag = '1'
            }

            //获取需采购后台数据
            console.log("传入参数内容为：",query);
            queryWaitSummaryOrderDetail(query).then(res => {
                this.tableData = res.data.data;
                console.log('获取的值：',this.tableData)
            });
          }
        }
    }
</script>-->

<style lang="scss">
  .execution {
      width: 100%;
      height: 100%;
      padding: 0 10px;
    .bg-container {
      height: 100%;
      background-color: #fff;
      .title {
          border-radius: 4px 4px 0 0;
          h2 {
              height: 55px;
              line-height: 55px;
              border-radius: 4px 4px 0 0;
              background-color: #e0e0e0;
              font-size: 21px;
              color: #333;
              padding-left: 20px;
          }
          .el-row {
              padding: 20px;
              line-height: 14px;
              font-size: 14px;
              span {
                  margin-left: 10px;
              }
          }
       }
      .content {
          width: 100%;
          padding: 0 20px 20px;
          border-radius: 0 0 4px 4px;
          .avue-crud {
              margin-left: 0;
              .el-card__body {
                  padding: 0;
                  .avue-crud__header{
                    margin-bottom: 10px;
                    .el-form--inline{
                      height: 40px;
                      line-height: 40px;
                    }
                  }
                  .avue-crud__menu{
                      margin-bottom: 10px;
                  }
              }
          }
      }
    }
  }
</style>
